package com.fsy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fsy.entities.Computer;
import com.fsy.service.ComputerService;
import com.fsy.mapper.ComputerMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author 凡凡
* @description 针对表【computer】的数据库操作Service实现
* @createDate 2022-03-15 10:25:14
*/
@Service
public class ComputerServiceImpl extends ServiceImpl<ComputerMapper, Computer>
    implements ComputerService{
    @Resource
    private ComputerMapper computerMapper;

    /**
     * 查询全部电脑
     * @param computer
     * @return
     */
    public List<Computer> findByComputer(Computer computer){
        int page = computer.getPage();
        int limit = computer.getLimit();
        int offset = (page-1)*limit;
        computer.setPage((page-1)*limit);
        computer.setOffset(offset);//计算偏移量
        return computerMapper.findByComputer(computer);
    }

    /**
     * 查询全部电脑条数
     * @param computer
     * @return
     */
    public int selectComputerCounts(Computer computer){
        return computerMapper.selectComputerCounts(computer);
    }
}




